package com.yanqu.road.server.cmd.union.cross.parergon;

import com.yanqu.road.pb.union.Parergon;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.union.UnionParergonMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.string.StringUtils;

@Cmd(code = Protocol.S_UNION_PARERGON_OPERATE_RECORD, desc = "经营记录")
public class OperateRecordCmd extends AbstractCommand {

    String unionUid;
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        unionUid = player.getUserInfo().getUnionUid();
        if (StringUtils.isNullOrEmpty(unionUid)) {
            ret = GameErrorCode.E_PARERGON_NOT_IN_UNION;
        }

        player.sendPacket(Protocol.C_UNION_PARERGON_OPERATE_RECORD, Parergon.OperateRecordReqMsg.newBuilder());
    }

    @Override
    public void sendData(GamePlayer player) {

        if(ret != 0){
            Parergon.OperateRecordRespMsg.Builder respMsg = Parergon.OperateRecordRespMsg.newBuilder();
            respMsg.setRet(ret);
            player.sendPacket(Protocol.U_UNION_PARERGON_OPERATE_RECORD, respMsg);
        }
    }
}
